1. Field of the Invention
The present invention relates to an apparatus and method for transferring digital data. More particularly, the invention relates to an apparatus and method of transferring of digital data in two byte units across a 16 bit data transfer bus connecting interface devices incorporated in data processor.
2. Description of the Related Art
Data processing devices such as personal computers and hard disk drives often incorporate small computer system interface (SCSI) controllers to manage the transfer of data during data processing operations. When two or more SCSI controllers are used in a digital processing device, data transfer occurs along SCSI buses, interconnecting the SCSI controllers. Data transferred across SCSI buses typically occurs a data sets divided into a plurality of data blocks. Each data block contains a predetermined number of bytes. Consequently, in designing a way to transfer data across SCSI buses, two key aspects of the design are the number of data blocks to be transferred across the bus at any given time, and the number of bytes contained in each data block. Generally speaking, the following four combinations of data blocks and bytes are possible for a single data set: combinations where the number of blocks is constant and the number of bytes is either even or odd, and combinations where the number of blocks is variable and the number of bytes is either even or odd.
FIG. 1 is a flowchart illustrating the operational routine of a conventional SCSI controller when it performs data transfer in units of 2 bytes using 16-bit bus lines. The first and second bytes of the transferred data are allocated to the lower and upper 8 bits of the 16-bit SCSI bus, respectively.
At step 101, the controller determines whether the number of bytes in a data block remaining to be transferred, ByN, is an even or odd number. If ByN is an even number, one block of data is transferred at step 119. Should this be the case, all of the 16 bits of the SCSI buses will contain data. Next, at step 120, the controller operates to subtract 1 from the number of blocks BLN remaining to be transferred. At step 121, the controller determines whether the result of the subtraction in Step 120 is zero. If the number of blocks to be transferred BLN is not zero, the controller repeats the operations at steps 119 to 121 until BLN reaches zero. When the number of BLN reaches zero, data transfer for one data set is considered complete.
Alternatively, if the controller determines at step 101 that the number of bytes ByN in a data block is not an even number, the data transfer routine advances to step 102. At step 102, the routine examines whether the number of blocks BLN remaining to be transferred is an odd number. If BLN is an even number, the controller advances execution of the data transfer routine to the procedure at step 112, where a byte counter is set to a first target value of ByN+1. At step 113, the number of bytes set for the first target value (ByN+1) is transferred as one block of data. The byte counter is then decremented. At step 114, the block number BLN is reduced by one.
At step 115, the byte counter is initially set to a second target value of ByN-1. Following this, at step 116, ByN-1 bytes of data are transferred as one block of data in the same manner as described at step 113. At step 117, the BLN number is decremented by one. Following the operations at steps 113 and 116, the transfer of two blocks of data (i.e., data of 2ByN bytes) is considered complete. At step 118, it is determined whether the number of data blocks not yet transferred, i.e., BLN is zero. If BLN is not zero, the operations at steps 112 through 118 are repeated until BLN reaches zero.
If it is determined at step 102 that BLN is an odd number, the routine examines, at step 103, whether the number BLN is 1. If BLN is 1, the process advances to the routine at step 104. At step 104, the current number BLN is reduced by one. At step 105, one block of data is transferred to complete the entire data transfer.
If, at step 103, BLN is determined to be an odd number greater than 1, the data transfer routine advances to the operation at step 106 where the byte counter is set have the first target value ByN+1. At step 107, ByN+1 bytes of data are transferred as one block of data, and the byte counter is decremented. At step 108, the current number BLN is reduced by one. Following this at step 109, the byte counter is set to a second target value of ByN-1. At step 110, ByN-1 bytes of data are transferred as one block of data in a manner similar to step 107. At step 111, the new value for BLN is reduced by one. Once finished with the procedures at steps 107 and 110, the controller routine then considers the transfer of two blocks of data (i.e., 2ByN bytes of data) as having been complete. The routine then returns to step 103, and repeats the operations at steps 106 to 111 until the value of BLN is equal to 1. When the value of BLN reaches 1, the operations at steps 104 and 105 are executed, completing the transfer of an odd block data set.
The above described conventional data transfer process can further be illustrated by reference to the following example and to FIG. 2. In this example, suppose that a data block to be transferred contains an odd number of bytes (e.g., 5), and that the variable number of blocks to be transferred is set to 1. As shown in FIG. 2, data transfer must occur three times. Five single-bytes of data B1, B2, B3, B4 and B5 (delineated by the bold line in FIG. 2) effectively form one data block. During the first data transfer, bytes B1 and B2 are supplied to the lower and upper bit lines of the SCSI bus, respectively. In the second data transfer, bytes B3 and B4 are supplied to the lower and upper bit lines of the SCSI bus, respectively. During the third data transfer, the last byte B5 of the block is supplied to the lower bit lines of the SCSI bus while dummy data X0 is supplied as ineffective byte data to the upper bit lines.
Next, assume that each data block contains an odd number of bytes (e.g., 5 bytes), and that the variable number of blocks to be transferred is an odd number greater or equal to 3. The first and second block transfers in this example, unlike in the previous example, contain no dummy data. This is because the fifth byte of the first block is combined with the first byte of the second block. In both examples, as shown in FIG. 2, both the last byte of data B5 in the last block and the ineffective dummy data X0 need to be supplied to the lower and upper bit lines of the SCSI bus, respectively.
Thus with conventional SCSI controllers, repeated odd block transfers of multiple data sets requires the use of dummy data for the last block of data, that is, when odd number of bytes are transferred. This significantly reduces data transfer efficiency. Transfer efficiency is further degraded by the need for a SCSI controller on the target end of the data transfer. Such a controller is needed to eliminate the added dummy byte from the transferred data. Moreover, conventional data transfer routines, such as that shown in FIG. 1, contain large numbers of processing steps. This factor further contributes to the inefficient operation of conventional controllers.